#include <iostream>
using namespace std;

/*
    【题目190】设计一个Bak类，实现银行某账号的资金往来账目管理，包括建账号、存入、取出等。
*/
#define MAX 100

class Bank
{
public:
    Bank() { top = 0; };
    void bankin(string date[], double money);
    void bankout(string date[], double money);
    void disp();

private:
    int top;
    string date[MAX];
    double money[MAX];
    double rest[MAX];
    double sum;
};
void Bank::bankin(string date[], double money)
{
    this->date[top] = date[top];
    this->money[top] = money;
    rest[top] = rest[top - 1] + money;
    sum += money;
    top++;
}
void Bank::bankout(string date[], double money)
{
    this->date[top] = date[top];
    this->money[top] = money;
    if (rest[top - 1] < money)
    {
        cout << "余额不足！" << endl;
        return;
    }
    rest[top] = rest[top - 1] - money;
    sum -= money;
    top++;
}
void Bank::disp()
{
    cout << "日期" << "\t\t" << "金额" << "\t" << "余额" << endl;
    for (int i = 0; i < top; i++)
    {
        cout << date[i] << "\t" << money[i] << "\t" << rest[i] << endl;
    }
    cout << "总金额为：" << sum << endl;
}

int main()
{
    Bank b1;
    string date[MAX];
    date[0] = "2020-01-01";
    b1.bankin({date}, 100);
    date[1] = "2020-01-02";
    b1.bankout({date}, 250);
    date[2] = "2020-01-03";
    b1.bankin({date}, 500);
    date[3] = "2020-01-04";
    b1.bankout({date}, 100); 
    b1.disp();

    return 0;
}